---
import { getCollection } from "astro:content"
import { CardGrid, LinkCard } from "@astrojs/starlight/components"

interface Props {
    directory: string
}
const { directory } = Astro.props

const pages = (
    await getCollection("docs", (entry) => entry.id.startsWith(directory + "/"))
).filter(({ id }) => id !== directory)
.sort((a, b) => (a.data.sidebar.order ?? 0) - (b.data.sidebar.order ?? 0))
---

<CardGrid
    >{
        pages.map(({ data, id }) => (
            <LinkCard
                title={data.title}
                href={"/genaiscript/" + id}
                description={data.description}
            />
        ))
    }</CardGrid
>
